<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace kitego\extend\storage\impl;

use kitego\extend\storage\Storage;
use kitego\services\common\FileService;
use OSS\OssClient;

class AliyunImpl extends Storage
{
    protected $client;
    protected $bucket;

    public function __construct($config)
    {
        $this->bucket = $config['aliyun_bucket'];
        $this->client = new OssClient($config['aliyun_access_key_id'], $config['aliyun_access_key_secret'], $config['aliyun_endpoint']);
    }

    /**
     * 上传
     */
    public function upload($path)
    {
        $this->client->uploadFile($this->bucket, $path . '/' . $this->fileName, $this->fileInfo['realPath']);

        return true;
    }

    /**
     * 删除
     */
    public function delete($path)
    {
        $this->client->deleteObjects($this->bucket, $path);

        return true;
    }

    public function water($path)
    {
        // TODO: Implement water() method.
    }
}